package com.example.administrator.yuejian23.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.yuejian23.Bean.MyCollect;
import com.example.administrator.yuejian23.Const;
import com.example.administrator.yuejian23.R;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2017/10/27.
 */

public class UserGuanZhuAdapter extends RecyclerView.Adapter {

    private List<MyCollect> myCollects;
    private Context context;
    private LayoutInflater layoutInflater;
    public UserGuanZhuAdapter(Context context,List<MyCollect> myCollects){
        this.context=context;
        this.myCollects=myCollects;
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View itemView=LayoutInflater.from(context).inflate(R.layout.item_user_collect,viewGroup,false);
        UserGuanZhuViewHolder holder=new UserGuanZhuViewHolder(itemView);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {

        UserGuanZhuViewHolder userGuanZhuViewHolder= (UserGuanZhuViewHolder) viewHolder;
        MyCollect guanzhu=myCollects.get(position);
        String guanzhu_name=guanzhu.getName();
        String guanzhu_pic= Const.PIC_URL+guanzhu.getThumb();
        userGuanZhuViewHolder.guanzhu_name.setText(guanzhu_name);
        Picasso.with(context).load(guanzhu_pic).into(userGuanZhuViewHolder.guanzhu_pic);
    }
    @Override
    public int getItemCount() {
        return myCollects.size();
    }
    public class UserGuanZhuViewHolder extends RecyclerView.ViewHolder{
        public TextView guanzhu_name;
        public ImageView guanzhu_pic;
        public View itemView;

        public UserGuanZhuViewHolder(View itemView) {
            super(itemView);
            this.itemView=itemView;
            guanzhu_name= (TextView) itemView.findViewById(R.id.guanzhu_name);
            guanzhu_pic= (ImageView) itemView.findViewById(R.id.guanzhu_pic);
        }
    }
}

